package phan.connection;

import java.util.*;
import java.util.Date;
import phan.connection.MySQLDBConnector;

public class OublierLoginBean {

    private String useremail;
    private String confirmuseremail;

    public OublierLoginBean() {
        useremail = "";
        confirmuseremail = "";


        errors = new Hashtable();
    }

    public boolean validate() {
        boolean allOk = true;
        MySQLDBConnector con = new MySQLDBConnector();
        // con.checkUserName(pseudo);

        if (useremail.equals("")) {

            errors.put("useremail", "Veuillez entrer votre email !");
            useremail = "";
            allOk = false;
        }
        System.out.print("check email 123" + con.checkEmailExiste(useremail));
        if (!con.checkEmailExiste(useremail) && !useremail.equals("")) {

            System.out.print("vao day thi co ma dien a");
            errors.put("useremail", "votre email n'est pas existe ");
            useremail = "";
            allOk = false;
        }
        if (confirmuseremail.equals("")) {

            getErrors().put("confirmuseremail", "Veuillez entrer votre email !");
            confirmuseremail = "";
            allOk = false;
        }
        if (!confirmuseremail.equals(useremail)) {

            getErrors().put("confirmuseremail", "confirmer votre email !");
            confirmuseremail = "";
            // confirmuseremail="";
            allOk = false;
        }

        return allOk;
    }
    private Hashtable errors;

    public String getErrorMsg(String s) {
        String errorMsg = (String) getErrors().get(s.trim());
        return (errorMsg == null) ? "" : errorMsg;
    }

    public Hashtable getErrors() {
        return errors;
    }

    /**
     * @param errors the errors to set
     */
    public void setErrors(Hashtable errors) {
        this.errors = errors;

    }

    /**
     * @return the useremail
     */
    public String getUseremail() {
        return useremail;
    }

    /**
     * @param useremail the useremail to set
     */
    public void setUseremail(String useremail) {
        this.useremail = useremail;
    }

    /**
     * @return the confirmuseremail
     */
    public String getConfirmuseremail() {
        return confirmuseremail;
    }

    /**
     * @param confirmuseremail the confirmuseremail to set
     */
    public void setConfirmuseremail(String confirmuseremail) {
        this.confirmuseremail = confirmuseremail;
    }
}

